package com.cyl.game.demos.web.controller;

import java.util.List;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cyl.game.demos.web.entity.Skin;
import com.cyl.game.demos.web.service.SkinService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/skins")
@RequiredArgsConstructor
public class SkinController {

    private final SkinService skinService;

    // 添加皮肤记录
    @PostMapping("/add")
    public String addSkin(@RequestBody Skin skin) {
        skinService.addSkin(skin);
        return "皮肤记录添加成功";
    }

    // 根据皮肤 ID 查询皮肤信息
    @GetMapping("/{skin_id}")
    public Skin getSkinById(@PathVariable("skin_id") Integer skin_id) {
        return skinService.getSkinById(skin_id);
    }

    // 根据英雄 ID 查询该英雄的所有皮肤信息
    @GetMapping("/hero/{hero_id}")
    public List<Skin> getSkinsByHeroId(@PathVariable("hero_id") Integer hero_id) {
        return skinService.getSkinsByHeroId(hero_id);
    }

    // 根据皮肤稀有度查询相应稀有度的所有皮肤
    @GetMapping("/rarity/{skin_rarity}")
    public List<Skin> getSkinsByRarity(@PathVariable("skin_rarity") String skin_rarity) {
        return skinService.getSkinsByRarity(skin_rarity);
    }

    // 获取所有可用的皮肤
    @GetMapping("/available")
    public List<Skin> getAvailableSkins() {
        return skinService.getAvailableSkins();
    }

    // 更新皮肤信息
    @PutMapping("/update")
    public String updateSkin(@RequestBody Skin skin) {
        skinService.updateSkin(skin);
        return "皮肤信息更新成功";
    }

    // 删除皮肤记录
    @DeleteMapping("/{skin_id}")
    public String deleteSkinById(@PathVariable("skin_id") Integer skin_id) {
        skinService.deleteSkinById(skin_id);
        return "皮肤记录删除成功";
    }
}